package ${q.pkg};

<#list q.imports as imps>
import ${imps};
</#list>

/**
 *  ${q.tableInfo.name}
 *
 *	@author ${q.author.name}(${q.author.english})
 *	@date ${q.createTime}
 */
public class ${q.className} implements Serializable {
    /**
     *
     */
    private static final long serialVersionUID = 1L;

<#list q.ei.fields as field>
    /**
     *  ${field.desc!""}
     */
    protected ${field.javaTypeName} ${field.name};
    protected List<${field.javaTypeName}> ${field.name}In;
    <#if field.javaTypeText>
    protected ${field.javaTypeName} ${field.name}XLike;
    protected ${field.javaTypeName} ${field.name}XLeft;
    protected ${field.javaTypeName} ${field.name}XRight;
    </#if>
    <#if field.javaTypeComparable>
    protected ${field.javaTypeName} ${field.name}Gt;
    protected ${field.javaTypeName} ${field.name}Gte;
    protected ${field.javaTypeName} ${field.name}Lt;
    protected ${field.javaTypeName} ${field.name}Lte;
    </#if>
    
</#list>
	
	public static ${q.className} build() {return new ${q.className}();}
	
<#list q.ei.fields as field>
    public ${field.javaTypeName} get${field.upName}() { return this.${field.name}; }
    public void set${field.upName}(${field.javaTypeName} ${field.name}) { this.${field.name} = ${field.name}; }
    public ${q.className} ${field.name}(${field.javaTypeName} ${field.name}) { set${field.upName}(${field.name}); return this; }
    
    public List<${field.javaTypeName}> get${field.upName}In() {return ${field.name}In;}
    public void set${field.upName}In(List<${field.javaTypeName}> ${field.name}In) { this.${field.name}In = ${field.name}In; }
    public ${q.className} ${field.name}In(List<${field.javaTypeName}> ${field.name}In) { set${field.upName}In(${field.name}In); return this; }
    public ${q.className} ${field.name}Append(${field.javaTypeName} ${field.name}) { if (${field.name}In == null) { ${field.name}In = new ArrayList<>(); } ${field.name}In.add(${field.name}); return this; }
    
    <#if field.javaTypeText>
    public ${field.javaTypeName} get${field.upNamet}XLike() {return ${field.name}XLike;}
    public void set${field.upName}XLike(${field.javaTypeName} ${field.name}XLike) { this.${field.name}XLike = ${field.name}XLike; }
    public ${q.className} ${field.name}XLike(${field.javaTypeName} ${field.name}XLike) { set${field.upName}XLike(${field.name}XLike); return this; }

    public ${field.javaTypeName} get${field.upName}XLeft() {return ${field.name}XLeft;}
    public void set${field.upName}XLeft(${field.javaTypeName} ${field.name}XLeft) { this.${field.name}XLeft = ${field.name}XLeft; }
    public ${q.className} ${field.name}XLeft(${field.javaTypeName} ${field.name}XLeft) { set${field.upName}XLeft(${field.name}XLeft); return this; }

    public ${field.javaTypeName} get${field.upName}XRight() {return ${field.name}XRight;}
    public void set${field.upName}XRight(${field.javaTypeName} ${field.name}XRight) { this.${field.name}XRight = ${field.name}XRight; }
    public ${q.className} ${field.name}XRight(${field.javaTypeName} ${field.name}XRight) { set${field.upName}XRight(${field.name}XRight); return this; }
    </#if>
    
    <#if field.javaTypeComparable>
    public ${field.javaTypeName} get${field.upName}Gt() {return ${field.name}Gt;}
    public void set${field.upName}Gt(${field.javaTypeName} ${field.name}Gt) { this.${field.name}Gt = ${field.name}Gt; }
    public ${q.className} ${field.name}Gt(${field.javaTypeName} ${field.name}Gt) { set${field.upName}Gt(${field.name}Gt); return this; }

    public ${field.javaTypeName} get${field.upName}Gte() {return ${field.name}Gte;}
    public void set${field.upName}Gte(${field.javaTypeName} ${field.name}Gte) { this.${field.name}Gte = ${field.name}Gte; }
    public ${q.className} ${field.name}Gte(${field.javaTypeName} ${field.name}Gte) { set${field.upName}Gte(${field.name}Gte); return this; }

    public ${field.javaTypeName} get${field.upName}Lt() {return ${field.name}Lt;}
    public void set${field.upName}Lt(${field.javaTypeName} ${field.name}Lt) { this.${field.name}Lt = ${field.name}Lt; }
    public ${q.className} ${field.name}Lt(${field.javaTypeName} ${field.name}Lt) { set${field.upName}Lt(${field.name}Lt); return this; }

    public ${field.javaTypeName} get${field.upName}Lte() {return ${field.name}Lte;}
    public void set${field.upName}Lte(${field.javaTypeName} ${field.name}Lte) { this.${field.name}Lte = ${field.name}Lte; }
    public ${q.className} ${field.name}Lte(${field.javaTypeName} ${field.name}Lte) { set${field.upName}Lte(${field.name}Lte); return this; }
    </#if>
    
    
</#list>	


    /**
     *  是否为空
     *  <p> 仅仅是每个字段的为空检测。若存在特殊空判，需要自行实现
     */
    public boolean isEmpty() {
    <#list q.ei.fields as field>
        if (${field.name} != null) {return false;}
        if (${field.name}In != null && !${field.name}In.isEmpty()) {return false;}
        <#if field.javaTypeText>
        if (${field.name}XLike != null && ${field.name}XLike.isEmpty()) {return false;}
        if (${field.name}XLeft != null && ${field.name}XLeft.isEmpty()) {return false;}
        if (${field.name}XRight != null && ${field.name}XRight.isEmpty()) {return false;}
        </#if>
        <#if field.javaTypeComparable>
        if (${field.name}Gt != null ) {return false;}
        if (${field.name}Gte != null ) {return false;}
        if (${field.name}Lt != null ) {return false;}
        if (${field.name}Lte != null ) {return false;}
        </#if>
    </#list>
        return true;
    }
    /**
     *  copy（注：这是浅拷贝）
     */
    public ${q.className} copy() {
        ${q.className} copy = new ${q.className}();
    <#list q.ei.fields as field>
        copy.${field.name} = ${field.name};
        copy.${field.name}In = ${field.name}In;
        <#if field.javaTypeText>
        copy.${field.name}XLike = ${field.name}XLike;
        copy.${field.name}XLeft = ${field.name}XLeft;
        copy.${field.name}XRight = ${field.name}XRight;
        </#if>
        <#if field.javaTypeComparable>
        copy.${field.name}Gt = ${field.name}Gt;
        copy.${field.name}Gte = ${field.name}Gt;
        copy.${field.name}Lt = ${field.name}Lt;
        copy.${field.name}Lte = ${field.name}Lte;
        </#if>
    </#list>
        return copy;
    }
}
